import { getFactoryDetailOrderList } from '@/api/merchant'
import { ref } from 'vue'
import { FactoryDetailOrder } from './types'

// 获取工单列表时的加载
const loading = ref(false)

// 工单列表
const list = ref<Array<FactoryDetailOrder>>([])

// 列表总条数
const total = ref(0)

/**
 * 获取
 * @param {string} id 商家id
 * @param {Object} param 分页配置
 * @param {number} param.limit 一页显示多少条
 * @param {number} param.page 当前页码
 */
const getList = async (id: string, param: { limit: number; page: number }) => {
  loading.value = true
  const res = await getFactoryDetailOrderList(id, param)
  list.value = res.data.data.rows
  loading.value = false
  total.value = Number(res.data.data.total)
}

export default {
  total,
  list,
  loading,
  getList,
}
